<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/WEB-INF/jsp/component/common.jsp"%>
<div class="hd">
		<div class="back">
			<button onclick="goBack()"></button>
		</div>
		<div class="info">
		   <div class="photo">
				<img src="${patient.userImage}" height="99%" width="99%"/>
			</div>
			<p>
				<span>姓&nbsp;&nbsp;&nbsp;&nbsp;名：${patient.realname}</span> <span>${patient.sex}：${patient.age}</span>
				<span>档案编号:</span>
			</p>
			<p>
				<span>身份证号：${patient.idCard}</span> <span>就诊卡号：${patient.medicalCardNum}</span>
			</p>
		</div>
		<div class="menu">
			<button class="last" onclick="changContent('1')" >个人档案</button>
			<button class="act" onclick="changContent('2')">体检记录</button>
			<button class="last">历史用药</button>
		</div>
	</div>
	<div class="cl"></div>
	<br/>
	<div class="record">
		<table style="width: 98%" cellSpacing=0 cellPadding=0 align=center
			border=0">
			<thead>
				<tr>
					<th>患者体检报告记录</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>
						<table id="examList" cellSpacing=0 cellPadding=0 border=0
							style="margin-top: -1px !important; margin-bottom: -1px !important;">
							<thead>
								<tr>
									<th style="display: none">id</th>
									<th style="display: none">mkExamCode</th>
									<th
										style="text-align: center; padding-left: 0px;">历次体检时间</th>
								</tr>
							</thead>
							<tbody>

							</tbody>
							<tfoot >
							 <tr>
					         <td class="last" colspan="3" ><ul id="examListPage" class="pagination-sm" style="margin:0px;line-height: 25px"></ul></td>
				             </tr>
							</tfoot>
						</table>
					</td>
				</tr>
		</table>
	</div>
	
	<script>
	
	function examList() {
		$('#examList').dataTable({
			"bInfo" : false, //页脚信息
			"bPaginate" : false, //分页
			"bFilter" : false, //过滤功能
			"oLanguage": {
				"sZeroRecords": "抱歉， 没有找到",
				"sInfoEmpty": "没有数据",
				"sZeroRecords": "没有检索到数据",
				},
			"aoColumns" : [ {
				"mData" : "id",
				"orderable" : false,
				"bVisible" : false
			}, {
				"mData" : "mkExamCode",
				"orderable" : false,
				"bVisible" : false,
			}, {
				"mData" : "examDateStr",
				"orderable" : false,
				 "mRender": function(data, type, full){
	            	  var inner = "<a href='#' onclick=showDetail('"+full.mkExamCode+"') >"+data+"</a>";
	            	  return inner;
	            }     
			} ]
		});
	}

	
	function examListPage(totalPages, startPage) {
		$('#examListPage').twbsPagination({
			totalPages : totalPages,
			startPage : startPage,
			visiblePages : 5,
			first : '首页',
			last : '末页',
			prev : '上一页',
			next : '下一页',
			onPageClick : function(event, page) {
				startPage = page;
				selectExamList(startPage);
			}
		});
	}

	function selectExamList(startPage) {
		var idCard = "${patient.idCard}";
		var ajaxUrl = "${ctx}/Exam/listExam";
		$.ajax({
			type : "post",
			url : ajaxUrl,
			data : {
				size : 5,//每页条数
				page : startPage, //当前页
				idCard : idCard
			},
			dataType : "json",
			success : function(json) {
				totalPages = json.page.totalPages;
				startPage = json.page.number + 1;
				if(totalPages==0){
					$('#examList').dataTable().fnClearTable();
				}else{
					$('#examList').dataTable().fnClearTable();
					$('#examList').dataTable().fnAddData(json.page.content,true);
				}
				examListPage(totalPages, startPage);
			}
		});
	}

	function selectExam(chartId) {
		 var idCard = "${patient.idCard}";
		 var url = "${ctx}/Exam/init?obj="+chartId+"&idCard="+idCard;
		 window.location.href = url;
	}
	
	function showDetail(code){
		 var idCard = "${patient.idCard}";
		 var pMenuId = "examPatients";
		 var url = "${ctx}/Exam/showDetail?idCard="+idCard+"&mkCode="+code+"&pMenuId="+pMenuId;
		 window.location.href = url;
	}
	function changContent(obj){
		var url = "#";
		var idCard = "${patient.idCard}";
		if(obj=="1"){
			url = "${ctx}/web/patient/baseData?idCard="+idCard;
		}else if(obj=="2"){
			url = "${ctx}/Exam/init?obj=exams1&idCard="+idCard;
		}else{
			url = "#";
		}
		window.location.href = url;
	}
	function goBack(){
		var url = "${ctx}/Exam/init?obj=patients";
		window.location.href = url;
	}
	</script>